package com.cauli.manage.notice.model.dto;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cauli.manage.notice.model.entity.Notice;
import com.cauli.model.dto.BaseQueryDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author Cauli
 * @date 2023-03-27 12:00
 * @description 公告添加参数
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "NoticeQueryDTO", description = "公告查询参数")
public class NoticeQueryDTO extends BaseQueryDTO {
    @ApiModelProperty("公告标题")
    private String title;

    @ApiModelProperty("平台（0管理端 1网盘）")
    private Integer platform;

    @ApiModelProperty("公告状态（0正常 1停用）")
    private Integer status;

    @Override
    public LambdaQueryWrapper<Notice> toLambdaQueryWrapper() {
        LambdaQueryWrapper<Notice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.like(StrUtil.isNotEmpty(title), Notice::getTitle, title)
                .eq(platform != null, Notice::getPlatform, platform)
                .eq(status != null, Notice::getStatus, status)
                .eq(Notice::getDeleted, 0);
        return lambdaQueryWrapper;
    }
}
